package com.only4play.httpapt.support.config.impl;

import com.only4play.httpapt.support.config.JsonPlaceholderConfigStorage;
import com.only4play.httpapt.support.constant.JsonPlaceholderConstants;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liyuncong
 * @version 1.0
 * @file JsonPlaceholderConfigStorageImpl
 * @brief JsonPlaceholderConfigStorageImpl
 * @details JsonPlaceholderConfigStorageImpl
 * @date 2024-08-16
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-08-16               liyuncong          Created
 */
public class JsonPlaceholderConfigStorageImpl implements JsonPlaceholderConfigStorage {

    private volatile String baseApiUrl;

    @Override
    public void setBaseUrl(String baseUrl) {
        this.baseApiUrl = baseUrl;
    }

    @Override
    public String getApiUrl(String path) {
        if (StringUtils.isBlank(baseApiUrl)) {
            baseApiUrl = JsonPlaceholderConstants.baseUrl;
        }
        return baseApiUrl + path;
    }
}
